/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.caresms.model.impl;

import com.caresms.model.Category_Master;
import com.caresms.model.Category_MasterModel;
import com.caresms.model.Category_MasterSoap;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the Category_Master service. Represents a row in the &quot;sms_Category_Master&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.caresms.model.Category_MasterModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link Category_MasterImpl}.
 * </p>
 *
 * @author cc
 * @see Category_MasterImpl
 * @see com.caresms.model.Category_Master
 * @see com.caresms.model.Category_MasterModel
 * @generated
 */
@JSON(strict = true)
public class Category_MasterModelImpl extends BaseModelImpl<Category_Master>
	implements Category_MasterModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a category_ master model instance should use the {@link com.caresms.model.Category_Master} interface instead.
	 */
	public static final String TABLE_NAME = "sms_Category_Master";
	public static final Object[][] TABLE_COLUMNS = {
			{ "CatId", Types.BIGINT },
			{ "countryId", Types.BIGINT },
			{ "CatName", Types.VARCHAR },
			{ "isActive", Types.BOOLEAN },
			{ "countsms", Types.INTEGER },
			{ "field1", Types.VARCHAR },
			{ "field2", Types.BOOLEAN },
			{ "field3", Types.INTEGER },
			{ "field4", Types.TIMESTAMP },
			{ "field5", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table sms_Category_Master (CatId LONG not null primary key,countryId LONG,CatName VARCHAR(75) null,isActive BOOLEAN,countsms INTEGER,field1 VARCHAR(75) null,field2 BOOLEAN,field3 INTEGER,field4 DATE null,field5 VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table sms_Category_Master";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.caresms.model.Category_Master"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.caresms.model.Category_Master"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.caresms.model.Category_Master"),
			true);
	public static long CATNAME_COLUMN_BITMASK = 1L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Category_Master toModel(Category_MasterSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Category_Master model = new Category_MasterImpl();

		model.setCatId(soapModel.getCatId());
		model.setCountryId(soapModel.getCountryId());
		model.setCatName(soapModel.getCatName());
		model.setIsActive(soapModel.getIsActive());
		model.setCountsms(soapModel.getCountsms());
		model.setField1(soapModel.getField1());
		model.setField2(soapModel.getField2());
		model.setField3(soapModel.getField3());
		model.setField4(soapModel.getField4());
		model.setField5(soapModel.getField5());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Category_Master> toModels(
		Category_MasterSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Category_Master> models = new ArrayList<Category_Master>(soapModels.length);

		for (Category_MasterSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.caresms.model.Category_Master"));

	public Category_MasterModelImpl() {
	}

	public long getPrimaryKey() {
		return _CatId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCatId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_CatId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Category_Master.class;
	}

	public String getModelClassName() {
		return Category_Master.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("CatId", getCatId());
		attributes.put("countryId", getCountryId());
		attributes.put("CatName", getCatName());
		attributes.put("isActive", getIsActive());
		attributes.put("countsms", getCountsms());
		attributes.put("field1", getField1());
		attributes.put("field2", getField2());
		attributes.put("field3", getField3());
		attributes.put("field4", getField4());
		attributes.put("field5", getField5());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long CatId = (Long)attributes.get("CatId");

		if (CatId != null) {
			setCatId(CatId);
		}

		Long countryId = (Long)attributes.get("countryId");

		if (countryId != null) {
			setCountryId(countryId);
		}

		String CatName = (String)attributes.get("CatName");

		if (CatName != null) {
			setCatName(CatName);
		}

		Boolean isActive = (Boolean)attributes.get("isActive");

		if (isActive != null) {
			setIsActive(isActive);
		}

		Integer countsms = (Integer)attributes.get("countsms");

		if (countsms != null) {
			setCountsms(countsms);
		}

		String field1 = (String)attributes.get("field1");

		if (field1 != null) {
			setField1(field1);
		}

		Boolean field2 = (Boolean)attributes.get("field2");

		if (field2 != null) {
			setField2(field2);
		}

		Integer field3 = (Integer)attributes.get("field3");

		if (field3 != null) {
			setField3(field3);
		}

		Date field4 = (Date)attributes.get("field4");

		if (field4 != null) {
			setField4(field4);
		}

		String field5 = (String)attributes.get("field5");

		if (field5 != null) {
			setField5(field5);
		}
	}

	@JSON
	public long getCatId() {
		return _CatId;
	}

	public void setCatId(long CatId) {
		_CatId = CatId;
	}

	@JSON
	public long getCountryId() {
		return _countryId;
	}

	public void setCountryId(long countryId) {
		_countryId = countryId;
	}

	@JSON
	public String getCatName() {
		if (_CatName == null) {
			return StringPool.BLANK;
		}
		else {
			return _CatName;
		}
	}

	public void setCatName(String CatName) {
		_columnBitmask |= CATNAME_COLUMN_BITMASK;

		if (_originalCatName == null) {
			_originalCatName = _CatName;
		}

		_CatName = CatName;
	}

	public String getOriginalCatName() {
		return GetterUtil.getString(_originalCatName);
	}

	@JSON
	public boolean getIsActive() {
		return _isActive;
	}

	public boolean isIsActive() {
		return _isActive;
	}

	public void setIsActive(boolean isActive) {
		_isActive = isActive;
	}

	@JSON
	public int getCountsms() {
		return _countsms;
	}

	public void setCountsms(int countsms) {
		_countsms = countsms;
	}

	@JSON
	public String getField1() {
		if (_field1 == null) {
			return StringPool.BLANK;
		}
		else {
			return _field1;
		}
	}

	public void setField1(String field1) {
		_field1 = field1;
	}

	@JSON
	public boolean getField2() {
		return _field2;
	}

	public boolean isField2() {
		return _field2;
	}

	public void setField2(boolean field2) {
		_field2 = field2;
	}

	@JSON
	public int getField3() {
		return _field3;
	}

	public void setField3(int field3) {
		_field3 = field3;
	}

	@JSON
	public Date getField4() {
		return _field4;
	}

	public void setField4(Date field4) {
		_field4 = field4;
	}

	@JSON
	public String getField5() {
		if (_field5 == null) {
			return StringPool.BLANK;
		}
		else {
			return _field5;
		}
	}

	public void setField5(String field5) {
		_field5 = field5;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			Category_Master.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Category_Master toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Category_Master)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		Category_MasterImpl category_MasterImpl = new Category_MasterImpl();

		category_MasterImpl.setCatId(getCatId());
		category_MasterImpl.setCountryId(getCountryId());
		category_MasterImpl.setCatName(getCatName());
		category_MasterImpl.setIsActive(getIsActive());
		category_MasterImpl.setCountsms(getCountsms());
		category_MasterImpl.setField1(getField1());
		category_MasterImpl.setField2(getField2());
		category_MasterImpl.setField3(getField3());
		category_MasterImpl.setField4(getField4());
		category_MasterImpl.setField5(getField5());

		category_MasterImpl.resetOriginalValues();

		return category_MasterImpl;
	}

	public int compareTo(Category_Master category_Master) {
		long primaryKey = category_Master.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Category_Master category_Master = null;

		try {
			category_Master = (Category_Master)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = category_Master.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		Category_MasterModelImpl category_MasterModelImpl = this;

		category_MasterModelImpl._originalCatName = category_MasterModelImpl._CatName;

		category_MasterModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Category_Master> toCacheModel() {
		Category_MasterCacheModel category_MasterCacheModel = new Category_MasterCacheModel();

		category_MasterCacheModel.CatId = getCatId();

		category_MasterCacheModel.countryId = getCountryId();

		category_MasterCacheModel.CatName = getCatName();

		String CatName = category_MasterCacheModel.CatName;

		if ((CatName != null) && (CatName.length() == 0)) {
			category_MasterCacheModel.CatName = null;
		}

		category_MasterCacheModel.isActive = getIsActive();

		category_MasterCacheModel.countsms = getCountsms();

		category_MasterCacheModel.field1 = getField1();

		String field1 = category_MasterCacheModel.field1;

		if ((field1 != null) && (field1.length() == 0)) {
			category_MasterCacheModel.field1 = null;
		}

		category_MasterCacheModel.field2 = getField2();

		category_MasterCacheModel.field3 = getField3();

		Date field4 = getField4();

		if (field4 != null) {
			category_MasterCacheModel.field4 = field4.getTime();
		}
		else {
			category_MasterCacheModel.field4 = Long.MIN_VALUE;
		}

		category_MasterCacheModel.field5 = getField5();

		String field5 = category_MasterCacheModel.field5;

		if ((field5 != null) && (field5.length() == 0)) {
			category_MasterCacheModel.field5 = null;
		}

		return category_MasterCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(21);

		sb.append("{CatId=");
		sb.append(getCatId());
		sb.append(", countryId=");
		sb.append(getCountryId());
		sb.append(", CatName=");
		sb.append(getCatName());
		sb.append(", isActive=");
		sb.append(getIsActive());
		sb.append(", countsms=");
		sb.append(getCountsms());
		sb.append(", field1=");
		sb.append(getField1());
		sb.append(", field2=");
		sb.append(getField2());
		sb.append(", field3=");
		sb.append(getField3());
		sb.append(", field4=");
		sb.append(getField4());
		sb.append(", field5=");
		sb.append(getField5());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(34);

		sb.append("<model><model-name>");
		sb.append("com.caresms.model.Category_Master");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>CatId</column-name><column-value><![CDATA[");
		sb.append(getCatId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>countryId</column-name><column-value><![CDATA[");
		sb.append(getCountryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>CatName</column-name><column-value><![CDATA[");
		sb.append(getCatName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isActive</column-name><column-value><![CDATA[");
		sb.append(getIsActive());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>countsms</column-name><column-value><![CDATA[");
		sb.append(getCountsms());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field1</column-name><column-value><![CDATA[");
		sb.append(getField1());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field2</column-name><column-value><![CDATA[");
		sb.append(getField2());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field3</column-name><column-value><![CDATA[");
		sb.append(getField3());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field4</column-name><column-value><![CDATA[");
		sb.append(getField4());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>field5</column-name><column-value><![CDATA[");
		sb.append(getField5());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Category_Master.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Category_Master.class
		};
	private long _CatId;
	private long _countryId;
	private String _CatName;
	private String _originalCatName;
	private boolean _isActive;
	private int _countsms;
	private String _field1;
	private boolean _field2;
	private int _field3;
	private Date _field4;
	private String _field5;
	private long _columnBitmask;
	private Category_Master _escapedModelProxy;
}